package no.ntnu.fp.handlers;

import java.util.List;

import no.ntnu.fp.handler.Handler;
import no.ntnu.fp.messages.Message;
import no.ntnu.fp.messages.impl.AppointmentsForEmployeeMessage;
import no.ntnu.fp.model.Appointment;
import no.ntnu.fp.model.CalendarModel;
import no.ntnu.fp.model.Employee;

public class AppointmentsForEmployeeHandler implements Handler {
	private final CalendarModel calendarModel;
	
	public AppointmentsForEmployeeHandler(CalendarModel calendarModel) {
		this.calendarModel = calendarModel;
	}

	@Override
	public void handleMessage(Message message) {
		AppointmentsForEmployeeMessage appointmentsForEmployeeMessage 
									= (AppointmentsForEmployeeMessage) message;
		
		List<Appointment> appointments 
							= appointmentsForEmployeeMessage.getAppointments();
		Employee employee = appointmentsForEmployeeMessage.getEmployee();

		calendarModel.setAppointmentsForEmployee(employee, appointments);
	}

}
